<script>
  import $ from '../dfish.js'
  import {
    h
  } from 'vue'

  export default {
    name: 'w-td',
    props: ['colspan', 'rowspan', 'align', 'valign'],
    inject: ['table', 'provideInBody'],
    render() {
      let ci = this.$.vnode.dfishColIndex
      let col = this.table.colgroup[ci] || false
      let colspan = this.colspan
      if (colspan == -1) {
        colspan = this.table.colgroup.length
      }
      let fixed = this.table.fixed
      return h('td', {
        class: ['w-td', this.provideInBody && col.class, {'f-form-hide': fixed ? col.fixed != fixed : col.fixed}],
        style: this.provideInBody && col.style,
        colspan,
        rowspan: this.rowspan,
        align: this.align || col.align,
        valign: this.valign || col.valign,
      }, this.$slots)
    }

  }
</script>
